package com.yx.changdao.web.template;

import com.yx.changdao.service.SysUserService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description: <br/>
 * Quartz定时任务 演示Demo
 * <p>
 * <br/>
 * @Auther: zhangqi
 * @create 2019/11/20 16:29
 */
@Component
public class QuartzJob extends QuartzJobBean {

    @Autowired
    SysUserService sysUserService;

    /**
     * 定时任务具体逻辑
     *
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //获取JobDetail中关联的数据
//        String msg = (String) jobExecutionContext.getJobDetail().getJobDataMap().get("msg");
        System.out.println("2+++++++++current time :" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "---");
        System.out.println("2+++++++++sysUserService = " + sysUserService);
    }
}
